// eslint-disable-next-line
import * as TYPE from '../actionType/bannerType';
// eslint-disable-next-line
import { bannerApi } from 'api';
const state = {
  bannerlist: []
};

const getters = {
  bannerlist: state => state.bannerlist
};

const actions = {
  bannerlist ({ commit, state, rootState }) {
    rootState.requesting = true;
    commit(TYPE.BANNER_LIST_REQUEST);
    bannerApi.list().then((response) => {
      console.log(response);
      rootState.requesting = false;
      commit(TYPE.BANNER_LIST_SUCCESS, response);
    }, (error) => {
      rootState.requesting = false;
      commit(TYPE.BANNER_LIST_FAILURE);
      console.log(error);
    });
  }
};

const mutations = {
  [TYPE.BANNER_LIST_REQUEST] (state) {

  },
  [TYPE.BANNER_LIST_SUCCESS] (state, bannerlist) {
    state.bannerlist = bannerlist.data;
  },
  [TYPE.BANNER_LIST_FAILURE] (state) {

  }
};

export default {
  state,
  getters,
  actions,
  mutations
};
